import i18n from '../i18n'
import Axios from 'axios'
import { Indicator, Toast  } from 'mint-ui'


Axios.interceptors.request.use(
  config => {
    Indicator.open({
      spinnerType: 'fading-circle'
    })
    return config
})

Axios.interceptors.response.use(
  response => {
    Indicator.close()
    return response
  },
  error => {
    Indicator.close()
    Toast({
      message: i18n.t('message.requestFailed')
    })
    return Promise.reject(error)
  })

export default Axios

